package com.scu.qingshi.infrastructure.dao.po;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.Version;
import com.baomidou.mybatisplus.annotation.TableId;

import java.io.Serializable;
import java.util.Objects;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.*;
import lombok.experimental.Accessors;

/**
 * <p>
 *
 * </p>
 *
 * @author 青时
 * @since 2022-03-05
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
@ApiModel(value = "InterUserMap对象", description = "")
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class InterUserMap implements Serializable {

    private static final long serialVersionUID = 1L;

    @TableId(value = "map_id", type = IdType.AUTO)
    private Integer mapId;

    private Integer interId;

    private Integer userId;

    @ApiModelProperty(value = "当前面试节点id")
    private Integer curNodeId;

    @ApiModelProperty(value = "冗余面试节点数")
    private Integer nodeCount;

    @ApiModelProperty(value = "0表示未审核 1表示审核通过 2表示审核不通过")
    private Integer pass;

    @ApiModelProperty(value = "0表示还未通过 1请表示面试通过 2表示面试失败")
    private Integer success;

    @ApiModelProperty(value = "申请理由")
    private String applyReason;

    @ApiModelProperty(value = "面试评述")
    private String review;

    private String openId;

    private String interName;

    /**
     * todo 此处可以根据不同俱乐部扩展出不同的规则
     * 现在默认为为参加过的（无论成功与否）不能多次申请
     */
    public boolean canApply() {
        if (!Objects.equals(0, success)) {
            return false;
        }
        return Objects.equals(pass, 2);
    }

    public void audit(Integer result) {

        final int PASS = 1;
        final int FAIL = 2;

        if (Objects.equals(result, PASS) || Objects.equals(result, FAIL)) {
            setPass(result);
        }
    }

    public void review(String content) {
        this.review = content;
    }

    public void judge(Boolean s) {
        // 面试成功！
        if (s){
            setSuccess(1);
        }else {
            setSuccess(2);
        }
    }
}
